package com.xy.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xy.entity.User;
import com.xy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xy
 * @since 2024-06-04
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/getUser")
    public Map<String, Object> getUser() {
        List<User> list = userService.list(null);
        Map<String, Object> map = new HashMap<>();
        map.put("userList", list);
        return map;
    }

    @GetMapping("/get")
    public IPage get(Integer size, Integer num) {
        Page page = new Page();
        page.setSize(size);
        page.setCurrent(num);
        userService.page(page, null);
        return page;
    }

}

